<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="/static/css/admin_login.css">
    <script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
</head>
<body>
<div class="container">
    <h2>管理员登录</h2>
    <div class="form-group">
        <label for="name">账号:</label>
        <input type="text" id="name" name="username" required>
    </div>
    <div class="form-group">
        <label for="password">密码:</label>
        <input type="password" id="password" name="password" required>
    </div>
    <div class="form-group">
        <button type="submit" id="login_but">登录</button>
    </div>
</div>

<script>
    $(document).ready(function () {
        $("#login_but").on("click",function () {
            $.ajax({
                url:"/admin/login",
                type:"post",
                dataType:"json",
                data:{
                    name:$("#name").val(),
                    password:$("#password").val(),
                },
                success:function (data) {
                    alert(data.data)
                    if(data.data == "登录成功!"){
                        console.log("进入到了这里")
                        window.location.replace("/myblogs")
                    }
                },
                error:function () {
                    alert("账号或者密码错误！")
                }
            })
        })
    })
</script>

</body>
</html>